package com.kfm.base.array2;

import java.util.Arrays;

public class Demo08 {

    public static void main(String[] args) {
        /*
            给数组头部添加元素
            数组长度固定
         */
        int[] arr = {1, 2, 3, 4};

        int num = 6;
        int[] arr1 = new int[arr.length + 1];

        // 复制数组
        for (int i = 0; i < arr.length; i ++){
            arr1[i + 1] = arr[i];
        }

        arr1[0]  = num;

        System.out.println(Arrays.toString(arr1));


    }
}
